Use worktree path for card identity instead of branch name#78
Merged
Conversation
Switch card identity from branch-based ({repoId}/{branch}) to path-based
(WorktreePath.value). Worktree paths are globally unique (filesystem
guarantee) and stable across git operations, solving issues with detached
HEAD worktrees that all shared the same '(detached)' branch name.
- Add WorktreePath.displayName for card title display (last path segment)
- Update Navigation.fs card keys and adjustFocusAfterCollapse to use paths
- Update App.fs findWorktree, renderCard, and card views for path-based keys
- Update ArchiveViews.fs card keys and display text
- Change server getSyncStatus to return path-keyed response map
- Update NavigationTests and ArchiveTests for new key format
Add WorktreeStatus.cardTitle: uses wt.Branch when available, falls back to WorktreePath.displayName for detached HEAD worktrees. This way 'main' still shows as 'main', while detached worktrees show their directory name (e.g. '.lm-ref-abc') instead of the unhelpful '(detached)'.
- Move DetachedBranchName constant to Shared.WorktreeStatus, remove duplicate from GitWorktree.fs - Move cardTitle UI function from Shared/Types.fs to Client/Components.fs - Rename FocusTarget.Card field label from scopedKey to path - Fix DemoFixture sync status keys to use worktree paths - Fix fixture JSON SyncStatus keys to use full worktree paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Card identity was based on
repoId/branchcomposite strings (e.g."CloudPlatform/feature/retry-logic"). This breaks for detached-HEAD worktrees where multiple cards can share the same branch value"(detached)", causing focus, sync events, and card state to collide.Changes
Path-based card identity — Replace
repoId/branchkeys withWorktreePathvalues throughout:Navigation.fs:FocusTarget.Cardnow holds a worktree path;visibleFocusTargets,repoNavSections, andadjustFocusAfterCollapseuse path-based lookupsApp.fs:renderCardbuildsscopedKeyfromWorktreePath.value wt.Path;StartSync/SyncStatusUpdateuse path keysWorktreeApi.fs:getSyncStatustranslates internalscopedBranchKey→ worktree path before returning to clientCard title display — Add
WorktreePath.displayName(extracts last path segment) andcardTitlehelper:Review-driven cleanup:
DetachedBranchNameconstant toShared.WorktreeStatus, eliminating duplicate literal inGitWorktree.fscardTitlefromShared/Types.fstoClient/Components.fs(UI function belongs with UI helpers)FocusTarget.Cardfield label fromscopedKeytopathDemoFixture.fssync status keys to use worktree path valuesworktrees.jsonfixtureSyncStatuskeys to use full worktree pathsTests
627 unit tests passing.